﻿using DryIoc;
using Main.DataBaseContext;
using Main.dto;
using Main.enums;
using Main.messageEvent;
using Main.utils;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Animation;
using static Main.App;
using static Main.utils.Constants;
namespace Main.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private string _title = "Prism Application";
        
        private readonly IRegionManager regionManager;

        public ICommand NavigationCommand { get; set; }

     

        public ObservableCollection<Menu> Menus { get; set; }


        public IValueConverter ToDoTaskStatusConverter  { get; set; } = new ToDoTaskStatusConvertor();

        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        //public ObservableCollection<>

        public MainWindowViewModel(IRegionManager regionManager)
        {

            
            NavigationCommand = new DelegateCommand<Menu>(NavigationChangedHandler);
         
            Menus = new ObservableCollection<Menu>() { 
            
                new Menu(){ 
                    Name="首页",
                    NameSpace=IndexViewName
                },
                new Menu(){
                    Name="待办事项",
                    NameSpace=ToDoTaskViewName
                },
                new Menu(){
                    Name="备忘录",
                    NameSpace="memos"
                },
                new Menu(){
                    Name="设置",
                    NameSpace="settings"
                },
            };
            //regionManager.Regions[MainViewContentControlName].RequestNavigate(IndexViewName);
            this.regionManager = regionManager;
        }

        private void NavigationChangedHandler(Menu menu)
        {
            regionManager.Regions[MainViewContentControlName].RequestNavigate(menu.NameSpace);
        }

    }
}
